package com.example.applyforaid.service.impl;


import com.example.applyforaid.controller.ManagerController;
import com.example.applyforaid.entity.ManagerUser;
import com.example.applyforaid.func.MessageEncryption;
import com.example.applyforaid.mapper.ManagerUserMapper;
import com.example.applyforaid.service.IManagerUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ManagerUserServiceImpl implements IManagerUserService {
    @Autowired
    private ManagerUserMapper managerUserMapper;

    public ManagerUser getUserAndVerifyService(String uid, String pwd) {
        ManagerUser mu;
        try{
            mu = managerUserMapper.selectByPrimaryKey(uid);
        }
        catch (Exception e)
        {
            return null;
        }
        if(mu.getManagerKey().equals(MessageEncryption.getSHA256(uid+pwd)))
            return mu;
        else
            return null;
    }
}
